<template>
	<view class="index-content">
		<!-- 	<TopBar :indexflag="true" :combakflag="false" :lang="true" :bottom="true" title="DikiDiki"
			barstyle="background-color:rgba(0,0,0,0)"></TopBar> -->
		<HeaderTitle title="DikiDiki" :bottom="true" :lang="false" :combakflag="true"  :mobile="true" ></HeaderTitle>
		<!-- <Header></Header> -->
		<view class="order-list">
			<view class="list"  v-if="orderdata" :dir="i18nLocale=='ug'?'rtl':''">
				<view class="time">
					<text>{{$t('TimePlaced')}}:</text>
					{{orderdata.order?orderdata.order.paid_at:''}}
					<u-icon name="checkmark-circle-fill" color="#45bc1b" size="25" ></u-icon>
				</view>
				<view class="order-item">
					<view class="item" v-for="(subitem,sub_index) in orderdata.content">
						<view class="left">
							<!-- <view class="index">{{sub_index+1}}.</view> -->
							<image :src="getImgSrc(subitem.img)" mode=""></image>
							<view class="name">{{i18nLocale=='ug'?subitem.ug_name:subitem.cn_name}}</view>
						</view>
						<view class="right">
							<view class="number">X{{subitem.qty}}</view>
							<view class="price">￥{{subitem.price}}</view>
						</view>
					</view>
					<view class="totalprice-box">
						<text>{{$t('TotalPrice')}}</text>
						<text class="totalprice">￥{{orderdata.fee}}</text>
					</view>
					<view class="button"  @click="handphone(orderdata.order.address.mobile)">
						<u-icon name="phone-fill" color="#fff" size="25"></u-icon>
					<text>{{$t('ContactMerchant')}}</text>
					</view>
					
				</view>
			</view>
			<Loading :show="loadshow" bgColor="" iconName="circle" :text="$t('Loading')"></Loading>
		</view>
	</view>
</template>

<script>
	import TopBar from "@/components/TopBar.vue"
	import Header from "./Header.vue"
	import HeaderTitle from "@/components/HeaderTitle.vue"
	import Navgtion from "./Navgtion.vue"
	import {
		getorderone,
	} from '@/api/all.js';

	export default {
		components: {
			TopBar,
			Header,
			HeaderTitle,
			Navgtion
		},
		data() {
			return {
				orderdata:'',
				loadshow:false

			}
		},
		computed: {
			i18nLocale() {
				return this.$i18n.locale;
			},
		},
		onLoad(e) {
			if(e.id){
				this.getOrders(e.id)
			}
		},
		methods: {
			getOrders(id) {
				let that = this;
				this.loadshow=true;
				getorderone({
					id:id
				}).then((res) => {
					if (res.code == 200) {
						let data = res.body;
						that.loadshow=false
						that.orderdata=data.data;
						
					}
				})
			},
			handphone(mobile) {
				uni.makePhoneCall({
					phoneNumber: String(mobile)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.index-content {
		width: 100%;
		height: 100%;
		box-sizing: border-box;

		.topnav {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-around;
			background-color: $uni-bg-color-box;
			box-sizing: border-box;
			padding: 20rpx 20rpx;
			font-size: $uni-font-size-base;

			.acitem {
				color: $uni-color-topic;
			}
		}

		.order-list {
			width: 100%;
			height: calc(100% - 370rpx);
			box-sizing: border-box;
			padding: 0rpx 20rpx;

			.list {
				width: 100%;
				background: #FFFFFF;
				box-shadow: $uni-bg-shadow;
				border-radius: $uni-border-radius-lg;
				margin-top: 20rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				padding: 20rpx 40rpx;
				box-sizing: border-box;

				.time {
					width: 100%;
					height: 80rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 28rpx;
					color: #000;

					text {
						color: #808080;
					}

					image {
						width: 80rpx;
						height: 80rpx;
					}
				}

				.order-item {
					width: 100%;
					display: flex;
					flex-direction: column;

					.item {
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: space-between;
						padding: 20rpx 0rpx;

						.left {
							display: flex;
							align-items: center;

							image {
								width: 120rpx;
								height: 120rpx;
								border-radius: 20rpx;
							}

							.name {
								color: $uni-color-title;
								font-size: $uni-font-size-base;
								padding: 0rpx 30rpx;
							}
						}

						.right {
							display: flex;
							align-items: center;

							.price {
								color: $uni-color-topic;
								font-size: $uni-font-size-base;
								padding: 0rpx 30rpx;
							}

							.number {
								color: $uni-text-color-grey;
								font-size: $uni-font-size-sm1;
								padding: 0rpx 30rpx;
							}

						}

					}

					.totalprice-box {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.totalprice {
							color: #f4464b;
							font-size: 45rpx;
						}
					}

					.button {
						background-color: $uni-color-topic;
						border-radius: $uni-border-radius-lg;
						padding: 20rpx 80rpx;
						margin: 0 auto;
						color: #fff;
						display: flex;
						align-items: center;
						text{
							padding: 0rpx 10rpx;
						}
					}


				}
			}
		}
	}
</style>